<div class="fm-content">
  <!-- 最上面标题栏 -->
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;流程配置
  </div>
  <!-- 内容 -->
  <div class="clwork">

    <!-- 查询框 -->
    <div class="top">
      <input nz-input placeholder="名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['actDefName:like']" />
      <input nz-input placeholder="ID" class="fm-input" [(ngModel)]="fs.queryObject['actDefID']" />
      <nz-button-group>
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">发布</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <!--左侧栏合同列表信息-->
    <div class="left top-left">
      <nz-tree nzAsyncData (nzClick)="fs.loadDataEx($event.node.key);" [nzData]="dic3.treeDatas">
      </nz-tree>
    </div>

    <!-- 右则样表单主体 -->
    <div class="right top-right">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
          [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
          [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
          (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead (nzSortChange)="fs.sort($event)" nzSingleSort>
            <tr>
              <th nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)"></th>
              <th nzWidth="20%">名称</th>
              <th nzWidth="10%">类型</th>
              <th nzWidth="10%">版本</th>
              <th nzWidth="30%">执行角色</th>
              <th nzWidth="10%">表单</th>
              <th nzWidth="10%">时限(小时)</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td><span (click)="editRow(data)" class="form-edit">{{data.actDefName}}({{data.actDefID}})</span>
              </td>
              <td>{{data.bpmTypeName}}</td>
              <td>{{data.version}}</td>
              <td>{{data.rolesName}}</td>
              <td>{{data.prjVI}}</td>
              <td>{{data.tlTotal}}</td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>
    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">名称</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="actDefName.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input required [(ngModel)]="fs.er.actDefName" id="actDefName" name="actDefName"
                  #actDefName="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">定义ID</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="actDefID.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input required [disabled]="!fs.er.FIELD_ISNEW" [(ngModel)]="fs.er.actDefID" name="actDefID"
                  #actDefID="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">类型</nz-form-label>
              <nz-form-control class="form-control" nzHasFeedback>
                <nz-form-control class="form-control">
                  <nz-select [(ngModel)]="fs.er.bpmType" (nzOpenChange)="dic2.load('0')" name="bpmType" required
                    [nzPlaceHolder]="'请选择'" class="form-control">
                    <nz-option *ngFor="let option of dic2.datas" [nzLabel]="option.display" [nzValue]="option.id">
                    </nz-option>
                    <nz-option *ngIf="dic2.isLoading" nzDisabled nzCustomContent>
                      <i nz-icon type="loading" class="loading-icon"></i>加载中...
                    </nz-option>
                  </nz-select>
                </nz-form-control>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">版本</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="vs.invalid?'error':'success'" nzHasFeedback>
                <nz-input-number required [(ngModel)]="fs.er.version" [disabled]="fs.er.bpmType==='1'" id="vs" name="vs"
                  #vs="ngModel" [nzMin]="1" [nzMax]="100" [nzStep]="1" class="form-control">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24" *ngIf="fs.er.bpmType==='1'">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">流程文件</nz-form-label>
              <nz-form-control class="form-control3">
                <nz-upload nzAction="{{ ffs.getUploadUrl() }}" [nzMultiple]="false"
                  [nzShowUploadList]="{ showPreviewIcon: true, showRemoveIcon: fs.er.FIELD_ISNEW }"
                  [(nzFileList)]="fs.er.file" name="file" (nzChange)="ffs.handleChange($event)">
                  <button nz-button [disabled]="!fs.er.FIELD_ISNEW"><i nz-icon
                      type="upload"></i><span>上传</span></button>
                </nz-upload>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24" *ngIf="fs.er.bpmType==='2'">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">节点</nz-form-label>
              <nz-form-control class="form-control3">
                <nz-table #childTable [nzData]="[{}]" [nzShowPagination]='false'>
                  <thead>
                    <tr>
                      <th nzWidth="15%">序号</th>
                      <th nzWidth="25%">节点ID</th>
                      <th nzWidth="40%">节点名称</th>
                      <th>
                        <span class="form-edit" (click)="fs.addLocalRow(fs.er, 'taskConfigs', ['id'])">
                          <i nz-icon type="plus-circle" nzTheme="outline"></i>
                        </span>
                      </th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr *ngFor="let c of fs.er.taskConfigs">
                      <td>
                        <input type="text" nz-input [(ngModel)]="c.taskorder" [ngModelOptions]="{standalone: true}" />
                      </td>
                      <td>
                        <input type="text" nz-input [(ngModel)]="c.taskdefid" [ngModelOptions]="{standalone: true}" />
                      </td>
                      <td>
                        <input type="text" nz-input [(ngModel)]="c.taskdefname" [ngModelOptions]="{standalone: true}" />
                      </td>
                      <td>
                        <span class="form-child-button" nz-popconfirm nzTitle="确认删除选择项?"
                          (nzOnConfirm)="fs.delLocalRow(fs.er.taskConfigs, c)" nzPlacement="bottomRight"
                          class="form-button">删除</span>
                      </td>
                    </tr>
                  </tbody>
                </nz-table>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary" [disabled]='actDefName.invalid || vs.invalid || actDefID.invalid'
              (click)="fs.save()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>
